package cn.youframe.comp.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Administrator
 * DateTime: 13-3-13 下午8:39
 * Desc:
 */
public class TreeNode<T> implements INode{
    private String nodeID;//节点ID
    private String parentID;//父节点ID
    private String nodeName;//节点名
    private List<TreeNode> children;//子节点
    private TreeNode parent;//父节点
    private T nodeObj;//节点对应的对象
    public TreeNode() {
    }

    /**
     * addChild 添加子节点
     *
     * @param treeNode TreeNode
     */
    public void addChild(TreeNode treeNode) {
        if(this.children==null){
            setChildren(new ArrayList<TreeNode>());
        }
        this.children.add(treeNode);
    }

    public void setNodeID(String nodeID) {
        this.nodeID = nodeID;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public void setChildren(List<TreeNode> children) {
        this.children = children;
    }

    public void setNodeObj(T nodeObj) {
        this.nodeObj = nodeObj;
    }

    public void setParent(TreeNode parent) {
        this.parent = parent;
    }

    public void setParentID(String parentID) {
        this.parentID = parentID;
    }

    public String getNodeID() {
        return nodeID;
    }

    public String getNodeName() {
        return nodeName;
    }

    public List<TreeNode> getChildren() {
        return children;
    }

    public T getNodeObj() {
        return nodeObj;
    }

    public TreeNode getParent() {
        return parent;
    }

    public String getParentID() {
        return parentID;
    }
}
